﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;

namespace Trangtrai.Controller.Global
{
    public class ConnectionClass
    {
        public static SqlConnection sqlConn = new SqlConnection();
        //const String connectionString = "Data Source=KINGOFHEAVEN-PC;Initial Catalog=TOM_MS;Integrated Security=True";
        static String connectionString = "";
        public static bool ConnectToDB()
        {
            getConnectionString();
            try
            {
                sqlConn.ConnectionString = connectionString;
                sqlConn.Open();
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
        }
        public static void closeConn()
        {
            sqlConn.Close();
        }
        private static string getConnectionString() {
            connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["TOM_MSConnectionString"].ConnectionString;
            return connectionString;
        }
    }
}